/**
 * 
 */
package fr.gfi.agraf.vue.action.ajax;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

import fr.gfi.agraf.service.IActiviteService;
import fr.gfi.agraf.utils.SpringFactory;
import fr.gfi.agraf.vue.bean.ActiviteDTO;
import fr.gfi.agraf.vue.bean.DonneesAjaxActivitesByPerimetre;
import fr.gfi.agraf.vue.bean.PerimetreDTO;

/**
 * @author Fw
 * 
 */
public class AjaxGetListeActivitesByPerimetre extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1027415118615683623L;

	private static final String ACTIVITE_SERVICE = "ActiviteService";

	/**
	 * Id récupéré de la page d'appel, pas de getter
	 */
	private Long idPerimetre;

	private Long idUtilisateur;
	/**
	 * La liste renvoyée => getter
	 */
	private List<ActiviteDTO> listeActivites;

	private PerimetreDTO perimetre;

	@Override
	public String execute() {

		// Je recupere les listes
		final IActiviteService activiteService = (IActiviteService) SpringFactory.getApplicationContext()
				.getBean(ACTIVITE_SERVICE);

		final DonneesAjaxActivitesByPerimetre donnees = activiteService
				.getListeActivitesByPerimetreAndUtilisateur(idPerimetre, idUtilisateur);

		listeActivites = donnees.getListeActiviteDTO();
		perimetre = donnees.getPerimetreDTO();

		return ActionSupport.SUCCESS;
	}

	/**
	 * @param idPerimetre
	 *            the idPerimetre to set
	 */
	public void setIdPerimetre(final Long idPerimetre) {
		this.idPerimetre = idPerimetre;
	}

	/**
	 * @return the listeActivitesDTO
	 */
	public List<ActiviteDTO> getListeActivites() {
		return listeActivites;
	}

	/**
	 * @return the perimetreDTO
	 */
	public PerimetreDTO getPerimetre() {
		return perimetre;
	}

	/**
	 * @param idUtilisateur
	 *            the idUtilisateur to set
	 */
	public void setIdUtilisateur(final Long idUtilisateur) {
		this.idUtilisateur = idUtilisateur;
	}

}
